<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <title>文字上下滑动按钮</title>
    <style>
        .app {
            width: 100%;
            height: 100vh;
            background-color: #ffffff;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .btn30 {
            height: 42px;
            position: relative;
            cursor: pointer;
            display: flex;
            overflow: hidden;
        }

        .btn-text30 {
            width: 36px;
            height: 42px;
            line-height: 42px;
            text-align: center;
            display: block;
            background-color: #457356;
            color: #ffffff;
            font-size: 16px;
            font-weight: 700;
            position: relative;
        }

        .btn-text30:after {
            width: 36px;
            height: 42px;
            position: absolute;
            background-color: #3185fa;
            color: #ffffff;
            z-index: 99;
            transition: 0.3s ease-in-out;
        }

        .btn-text30:nth-of-type(1):after {
            content: '学';
            top: -42px;
            left: 0;
        }

        .btn-text30:nth-of-type(2):after {
            content: '无';
            top: 42px;
            left: 0px;
        }

        .btn-text30:nth-of-type(3):after {
            content: '止';
            top: -42px;
            left: 0;
        }

        .btn-text30:nth-of-type(4):after {
            content: '境';
            top: 42px;
            left: 0px;
        }

        .btn30:hover .btn-text30:after {
            top: 0;
        }
    </style>
</head>

<body>
    <div class="app">
        <div class="btn30">
            <span class="btn-text30">探</span>
            <span class="btn-text30">索</span>
            <span class="btn-text30">未</span>
            <span class="btn-text30">知</span>
        </div>
    </div>
</body>

</html>